<fieldset>
	<div class="orders view">
		<h2><?php  echo __('Order'); ?></h2>
		<br />
		

		<table class="inlineTable">
	   		<tr>
				<td class="heading"><?php echo __('Order Id'); ?></td>
				<td class="data"><?php echo h($order['Order']['id']); ?></td>
		    </tr>
		                
		    <tr>
				<td class="heading"><?php echo __('Date Created'); ?></td>
				<td class="data"><?php echo h($order['Order']['created']); ?></td>
			</tr>
		                
			<tr>
		        <td class="heading"><?php echo __('Supplier'); ?></td>
				<td class="data"><?php echo $this->Html->link($order['Suppliers']['supplierName'], array('controller' => 'suppliers', 'action' => 'view', $order['Suppliers']['id'])); ?></td>
		    </tr>
		       
		    <tr>
				<td class="heading"><?php echo __('Order Status'); ?></td>
				<td class="data"><?php 	if($order['Order']['status'] == '0'){
											echo 'Not Completed';
										}
										else if($order['Order']['status'] == '2'){
											echo 'Partially Completed';
										}
										else{
											echo 'Completed';
										} ?>
				</td>
		    </tr>
		</table>

		<br /><br />
		<div class="newbutton">
			<ul>
				<li><?php echo $this->Html->link(__('Back'), array('action' => 'index')); ?></li>
				<li><?php echo $this->Form->postLink(__('Archive this Order'), array('action' => 'delete', $order['Order']['id']), null, __('Are you sure you want to archive # %s?', $order['Order']['id'])); ?></li>
		<?php if ($order['Order']['status'] != '1'){ ?>
				<li><?php echo $this->Html->link(__('Receive Order'), array('controller' => 'deliveries' ,'action' => 'delivery', $order['Order']['id'])); ?></li>
		<?php } ?>
				<li><?php echo $this->Html->link(__('Add Salon Accessory Product'), array('action' => 'addaccessory', $order['Order']['id'])); ?></li>
			</ul>
		</div>
		<br /><br /><br >


		<!doctype html>

	<script src ="app/webroot/js/bootstrap/bootstrap.js"></script>
	<script>
		$('#myTab a').click(function (e) {
			e.preventDefault()
			$(this).tab('show')

		})
	</script>

	<ul class="nav nav-tabs" id="myTab">
		<li class="active"><a href="#tab-1" data-toggle="tab">Products Ordered</a></li>
		<li><a href="#tab-2" data-toggle="tab">Deliveries</a></li>
		<li><a href="#tab-3" data-toggle="tab">Gifts</a></li>
	</ul>


	<div class="tab-content">
		<div class="tab-pane active" id="tab-1">
			<?php if (!empty($order['Product'])){?> 
			<table class="table" cellpadding="0" cellspacing="0">
				<tr>
						<th>Brand</th>
						<th>Range</th>
						<th>Category</th>
						<th>Description</th>
						<th>Size</th>
						<th>Order Quantity</th>
						<th>Delivered Quantity</th>
						<th>Action</th>
				</tr>
				<?php foreach ($order['Product'] as $product): ?>
				<tr>
					<td>
						<?php echo $this->Html->link($product['Brand']['name'], array('controller' => 'productsbrands', 'action' => 'view', $product['productsbrands_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Range']['name'], array('controller' => 'productsranges', 'action' => 'view', $product['productsranges_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Category']['name'], array('controller' => 'productscategories', 'action' => 'view', $product['productscategories_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['description'], array('controller' => 'products', 'action' => 'view', $product['id'])); ?>
					</td>
					<td><?php echo h($product['size']); ?>&nbsp;</td>
					<td><?php echo h($product['Ordersproduct']['orderQty']); ?>&nbsp;</td>
					<td><?php echo h($product['Ordersproduct']['deliveredQty']); ?>&nbsp;</td>
					<td><?php echo $this->Html->link(__('Edit Quantity'), array('action' => 'editqty', $product['Ordersproduct']['id'])); ?></td>
				</tr>
				
				<?php endforeach; ?>
			</table> 
		<?php } else { echo 'No products was ordered in this order.'; } ?> 
		</div> 

		<div class="tab-pane" id="tab-2">
		<?php if (!empty($order['Delivery'])){?> 
		<table class="table" cellpadding="0" cellspacing="0">
				<tr>
						<th>Date Received</th>
						<th>Action</th>
				</tr>
				<?php foreach ($order['Delivery'] as $d): ?>
				<tr>
					<td><?php echo h($d['created']); ?></td>
					<td>
						<?php echo $this->Html->link('View Delivery', array('controller' => 'deliveries', 'action' => 'view', $d['id'])); ?>
					</td>
				</tr>
				
				<?php endforeach; ?>
			</table> 
	<?php } else{ echo 'No delivery has been received for this order.';} ?> 
	</div>

		<div class="tab-pane" id="tab-3">
		<?php if (!empty($order['Gifts'])){?> 
		<table class="table" cellpadding="0" cellspacing="0">
				<tr>
						<th>Brand</th>
						<th>Range</th>
						<th>Category</th>
						<th>Description</th>
						<th>Size</th>
						<th>Delivered Quantity</th>
				</tr>
				<?php foreach ($order['Gifts'] as $product): ?>
				<tr>
					<td>
						<?php echo $this->Html->link($product['Brand']['name'], array('controller' => 'productsbrands', 'action' => 'view', $product['Products']['productsbrands_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Range']['name'], array('controller' => 'productsranges', 'action' => 'view', $product['Products']['productsranges_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Category']['name'], array('controller' => 'productscategories', 'action' => 'view', $product['Products']['productscategories_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Products']['description'], array('controller' => 'products', 'action' => 'view', $product['Products']['id'])); ?>
					</td>
					<td><?php echo h($product['Products']['size']); ?>&nbsp;</td>
					<td><?php echo h($product['deliveredQty']); ?>&nbsp;</td>
				</tr>
				
				<?php endforeach; ?>
			</table> 
	<?php } else{ echo 'No gift was delivered for this order.';} ?> 
	</div>
		

	</div>

</fieldset>